<!DOCTYPE html>
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<html>
  <head>
    <meta charset="UTF-8">
    <title>Title1</title>
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<script src="<%=basePath %>web/js/jquery.min.js"></script>
    <script src="<%=basePath %>web/js/jquery.easyui.min.js"></script>
    <script src="<%=basePath %>web/js/easyui-lang-zh_CN.js"></script>
    <link rel="stylesheet" href="<%=basePath %>web/themes/icon.css">
    <link rel="stylesheet" href="<%=basePath %>web/themes/default/easyui.css">
    <link rel="stylesheet" href="<%=basePath %>web/css/wu.css">
 </head>
     <script>
        var  selectIndex = -1;

        function hideTable(){
            $("#searchdiv").toggle();
        }
       $(function(){
             $("#reset_btn").click(function(){
             	$("#form1")[0].reset();
             	$("#productList").datagrid('load',serializeForm);
             })
             $("#productList").datagrid({
                url:'<%=basePath%>company/getCompanyList',
                pageNumber:1,
                pageSize:5,
                pageList:[5,10,15],
                pagination:true,
                checkOnSelect:true,
                columns:[[
                    {field:'code',title:'客户代号',width:140},
                    {field:'name',title:'客户名称',width:180},
                    {field:'type',title:'类型',width:70,
                    formatter:function (value,row,index) {
                     if(row.type==1){
                       var str="客户"
                     }else if(row.type==3){
                       var str="客户/供应商"
                     }else if(row.type==2){
                     	 var str="供应商"
                     }
                     return str;
                    }
                    },
                    {field:'linkman',title:'联系人员',width:80},
                    {field:'phone',title:'电话',width:100},
                    {field:'fax',title:'传真',width:100},
                    {field:'address',title:'地址',width:180}
                ]],
                toolbar:'#wu_toolbar'
            })
	         $("#search_btn").click(function(){
		       var form=$("#form1");
	  		 $("#productList").datagrid('load',serializeForm(form));
	         })
	         
	         	$('#productList').datagrid({
				onDblClickRow : function(index, row) {
					var name=row.name;
					var linkman=row.linkman;
					var phone=row.phone;
					var fax=row.fax;
					var data=new Array();
					data[0]=name;
					data[1]=linkman;
					data[2]=phone;
					data[3]=fax;
					parent.bindValue(data);
					//和销毁配合使用
					parent.closeSon();
					
				},
				onClickRow:function(index, row) {
				$(this).datagrid("unselectRow",index);
					var name=row.name;
					var linkman=row.linkman;
					var phone=row.phone;
					var fax=row.fax;
					var data=new Array();
					data[0]=name;
					data[1]=linkman;
					data[2]=phone;
					data[3]=fax;
					parent.bindValue(data);
				}
			});
        })
        
        //将表单序列化
		function serializeForm(form){
			var obj={};
			$.each(form.serializeArray(),function(index){
				  if(obj[this['name']]){
					obj[this['name']]=obj[this['name']]+','+this['value']
				 }else{
				   obj[this['name']]=this['value'];
				 }
			});
			return obj;
		}  
     </script>
  
  <body>
    <div id="wu_toolbar">
    <input type="hidden" id="path" value="${pageContext.request.contextPath}"/>
    <div id="searchdiv" style="display: block;width: 100%;">
        <form name="form1" id="form1"> 
            <table width="100%" border="0" cellspacing="0" style="background-color:#c9dfff;" >
                <tbody><tr>
                    <td width="70"><b>检索条件:</b></td>
                    <td width="70" align="right">单位名称:</td>
                    <td width="150" align="left"><input name="name" class="easyui-textbox" type="text" id="findName" value="" maxlength="100" style="height:30px"></td>
                    <td width="70" align="right">单位代号:</td>
                    <td width="150" align="left"><input name="code" class="easyui-textbox" type="text" id="findCode" value="" maxlength="100" style="height:30px"></td>
                    <td width="70" align="right">单位类别:</td>
                    <td width="150" align="left">
                    <select name="type" id="findType" class="easyui-combobox" style="width:120px;height:30px" panelHeight="150px">
                   
		                   	<option value="0">-请选择-</option>
		                    <option value="1">客户</option> 
		                    <option value="3">客户/供应商</option> 
		                    <option value="2">供应商</option>
                    </select>
                    </td>
                    <td width="72">
                        <a id="search_btn" href="#" class="easyui-linkbutton" data-options="iconCls:'icon-search'">搜索</a>
                    </td>
                    <td width="72">
                        <a id="reset_btn" href="#" class="easyui-linkbutton" data-options="iconCls:'icon-refresh'">重置</a>
                    </td>
                    <td width="0"></td>
                </tr>
                </tbody>
            </table>
            <input type="hidden" id="menuCode" value="100001001">
        </form>
    </div>
</div>
<div id="productList" class="easyui-datagrid">

</div>
  </body>
</html>
